SET SERVER_NAME=kafka
SET IMAGE_NAME=bitnami/kafka
SET VERSION=3.7.0
SET PORT=9092
SET PASSWORD=kafka2024
SET DIR=/c/home/app/docker/%SERVER_NAME%

docker stop %SERVER_NAME%
docker rm %SERVER_NAME%
docker run -d --name %SERVER_NAME% ^
-p %PORT%:%PORT% ^
-e KAFKA_ENABLE_KRAFT=true ^
-e KAFKA_CFG_NODE_ID=0 ^
-e KAFKA_KRAFT_CLUSTER_ID=Uu3NlUZ5TBaUEL-Ld8hC1g ^
-e KAFKA_CFG_PROCESS_ROLES=controller,broker ^
-e KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@localhost:9093 ^
-e KAFKA_CFG_LISTENERS=SASL_SSL://:9092,CONTROLLER://:9093 ^
-e KAFKA_CFG_ADVERTISED_LISTENERS=SASL_SSL://localhost:9092 ^
-e KAFKA_CLIENT_USERS=kafka ^
-e KAFKA_CLIENT_PASSWORDS=%PASSWORD% ^
-e KAFKA_CLIENT_LISTENER_NAME=SASL_SSL ^
-e KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:SASL_PLAINTEXT,SASL_SSL:SASL_SSL ^
-e KAFKA_CFG_SASL_MECHANISM_CONTROLLER_PROTOCOL=PLAIN ^
-e KAFKA_CONTROLLER_USER=kafka ^
-e KAFKA_CONTROLLER_PASSWORD=%PASSWORD% ^
-e KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER ^
-e KAFKA_TLS_TYPE=JKS ^
-e KAFKA_CERTIFICATE_PASSWORD=%PASSWORD% ^
-e KAFKA_INTER_BROKER_USER=kafka ^
-e KAFKA_INTER_BROKER_PASSWORD=%PASSWORD% ^
-e KAFKA_CFG_INTER_BROKER_LISTENER_NAME=SASL_SSL ^
-e KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN ^
-v %DIR%/truststore/server.keystore.jks:/opt/bitnami/kafka/config/certs/kafka.keystore.jks:ro ^
-v %DIR%/truststore/server.truststore.jks:/opt/bitnami/kafka/config/certs/kafka.truststore.jks:ro ^
--restart=always %IMAGE_NAME%:%VERSION%